<%@language=vbscript%>
<% 
	Session("FormName")="F45"
	Session("VanBan")=""
%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file=..\getFormName.inc-->
<!--#include file="..\jvGrid.inc"-->
<!--#include file="..\RootContent.inc"-->
<!--#include file="..\pageSelected.inc"-->
<!--#include file="..\jvfunction.inc"-->

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="vi">
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>
<%	
	bComm=Request("bComm")
	bNam=Request("bNam")
	bImgAttach="../Images/attach.gif"

' HienSX	
	sort=request("sort")
	if sort="" then sort="RevDate"
	Select case sort
		Case "Date":
			oSQL=" order by Ngayden, Soden"
			bImgDate="../Images/up.gif"
			bImgNum=""
			bImgSubject=""
			bImgPlaceSend=""
		Case "RevDate":
			oSQL=" order by Ngayden DESC,Soden DESC"
			bImgDate="../Images/down.gif"
			bImgNum=""
			bImgSubject=""
			bImgPlaceSend=""
		Case "Num":
			oSQL=" order by Soden,Ngayden"
			bImgDate=""
			bImgNum="../Images/up.gif"
			bImgSubject=""
			bImgPlaceSend=""
		Case "RevNum":
			oSQL=" order by Soden DESC,Ngayden DESC"
			bImgDate=""
			bImgNum="../Images/down.gif"
			bImgSubject=""
			bImgPlaceSend=""
		Case "Subject":
			oSQL=" order by Trichyeu,Ngayden,Soden"
			bImgDate=""
			bImgNum=""
			bImgSubject="../Images/up.gif"
			bImgPlaceSend=""
		Case "RevSubject":
			oSQL=" order by Trichyeu DESC,Ngayden DESC,Soden DESC"
			bImgDate=""
			bImgNum=""
			bImgSubject="../Images/down.gif"
			bImgPlaceSend=""
		Case "PlaceSend":
			oSQL=" order by Noigui,Ngayden,Soden"
			bImgDate=""
			bImgNum=""
			bImgSubject=""
			bImgPlaceSend="../Images/up.gif"
		Case "RevPlaceSend":
			oSQL=" order by Noigui DESC,Ngayden DESC,Soden DESC"
			bImgDate=""
			bImgNum=""
			bImgSubject=""
			bImgPlaceSend="../Images/down.gif"
		Case "Attach":
			oSQL=" order by attach"
			bImgDate=""
			bImgNum=""
			bImgSubject=""
			bImgPlaceSend=""
		Case "RevAttach":
			oSQL=" order by attach DESC"
			bImgDate=""
			bImgNum=""
			bImgSubject=""
			bImgPlaceSend=""
	End Select

	Select case bComm
		Case "delete"
			bID=Request("TxtID")
			'Tao Transaction
			On Error resume next
			Conn.BeginTrans
		'Xoa bang Totrinh
			sSQL="Delete from Totrinh where ID ='"& modistring(bID) &"'"
			Conn.Execute sSQL
		'Xoa file dinh kem
			sSQL="Select * from Vanban_Noidung where Mavanthu ='"& modistring(bID) &"' and Loaivanthu = '7'"
			set RecTmp=server.CreateObject("ADODB.Recordset")
			RecTmp.CursorType=3
			RecTmp.CacheSize=5
			RecTmp.Open sSQL,Conn
			Set File = Server.CreateObject("ActiveFile.File")
			do while not RecTmp.EOF
				File.Name=RootContent & "Upload\"& cstr(bNam) &"\Totrinh\"& RecTmp("Tentep")
				if File.Exists() then
					File.Delete()
				end if
				RecTmp.MoveNext
				if Err.number<>0 then
					Exit Do
				end if
			Loop
			set File=nothing
			RecTmp.close
			set RecTmp=nothing
			'Xoa bang vanban_noidung
			sSQL="Delete from Vanban_Noidung where Mavanthu ='"& modistring(bID) &"' and Loaivanthu = '7'"
			Conn.Execute sSQL

			'Ket Thuc Trasaction
			if Err.number=0 then
				Conn.CommitTrans				
				bTrangthai=1				
			else
				bTrangthai=0
				Conn.RollbackTrans
			end if

			'Ghi nhan Ai da login thanh cong
			bHoten=Session("bHoten")
			bNgaygio=cstr(Date()) &" "& cstr(Time())
			bChucnang="Cap nhat To trinh - Giao viec"
			bIDTailieu=bID
			bDongtac="Xo&#225;"
			sSQL="insert into loguser(Tennguoisudung,ngaygio,chucnangdung,dongtac,IDTailieu,Trangthai) Values('"& bHoten _
				&"','"& bNgaygio &"','"& bChucnang &"','"& bDongtac &"','"& bIDTailieu &"','"& bTrangthai &"')"
			Conn.Execute sSQL							

'Admin
			if Session("IsAdmin") then
				if session("sSQLTotrinh")="" then
					sSQL="Select * from Totrinh" & " "& oSQL
					bPrintValue="Select * from Totrinh"
				else
					bPrintValue=session("sSQLTotrinh")
					sSQL=session("sSQLTotrinh") & " "& oSQL
				end if
			else
				bNhom="Select Quyen_Nhom.Mavanthu FROM Canbo INNER JOIN Canbo_Nhom ON Canbo.Macanbo =Canbo_Nhom.Macanbo INNER JOIN Nhom ON dbo.Canbo_Nhom.Manhom=Nhom.Manhom INNER JOIN Quyen_Nhom ON Nhom.Manhom = Quyen_Nhom.MaNhom WHERE (Canbo.Macanbo = '"& Session("bMaCB") & "') and Quyen_nhom.Maloaivanthu ='7'"

				bDonvi="Select Quyen_Nhom.Mavanthu FROM Donvi INNER JOIN Quyen_Nhom on Donvi.ID = Quyen_Nhom.Manhom where Donvi.Madonvi like '"& Session("bMaDonVi") &"' and Quyen_Nhom.Maloaivanthu = '7'"
				
				bCanbo="Select Mavanthu From Quyen Where Macanbo ='" & Session("bMaCB") & "' and Maloaivanthu='7'"

'Co quyen "Phan quyen doc TT"			
				if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),4)="1" then
					if session("sSQLTotrinh")="" then
						sSQL="Select * from Totrinh Where DonviXL like '%" & Session("bMaDonVi") &"' OR Totrinh.ID in (" & bNhom &") OR Totrinh.ID in (" & bDonvi &") OR Totrinh.ID in (" & bCanbo &") OR NguoiCN='" & Session("bMaCB") &"' "& oSQL
						bPrintValue="Select * from Totrinh Where DonviXL like '%" & Session("bMaDonVi") &"' OR Totrinh.ID in (" & bNhom &") OR Totrinh.ID in (" & bDonvi &") OR Totrinh.ID in (" & bCanbo &") OR NguoiCN='" & Session("bMaCB") &"' "					
					else
						bPrintValue=session("sSQLTotrinh")
						sSQL=session("sSQLTotrinh") & " "& oSQL
					end if
				else
'Cac truong hop #
					if session("sSQLTotrinh")="" then
						sSQL="Select * from Totrinh Where Totrinh.ID in (" & bNhom &") OR Totrinh.ID in (" & bDonvi &") OR Totrinh.ID in (" & bCanbo &") OR NguoiCN='" & Session("bMaCB") &"' "& oSQL
						bPrintValue="Select * from Totrinh Where Totrinh.ID in (" & bNhom &") OR Totrinh.ID in (" & bDonvi &") OR Totrinh.ID in (" & bCanbo &") OR NguoiCN='" & Session("bMaCB") &"' "
					else
						bPrintValue=session("sSQLTotrinh")
						sSQL=session("sSQLTotrinh") & " "& oSQL
					end if
				end if
			end if

		Case "search"
		%>
			<!--#include file="funcSearch.inc"-->
		<%
		Case else
'Admin
			if Session("IsAdmin") then
				if session("sSQLTotrinh")="" then
					sSQL="Select * from Totrinh" & " "& oSQL
					bPrintValue="Select * from Totrinh"
				else
					bPrintValue=session("sSQLTotrinh")
					sSQL=session("sSQLTotrinh") & " "& oSQL
				end if
			else
				bNhom="Select Quyen_Nhom.Mavanthu FROM Canbo INNER JOIN Canbo_Nhom ON Canbo.Macanbo =Canbo_Nhom.Macanbo INNER JOIN Nhom ON dbo.Canbo_Nhom.Manhom=Nhom.Manhom INNER JOIN Quyen_Nhom ON Nhom.Manhom = Quyen_Nhom.MaNhom WHERE (Canbo.Macanbo = '"& Session("bMaCB") & "') and Quyen_nhom.Maloaivanthu ='7'"

				bDonvi="Select Quyen_Nhom.Mavanthu FROM Donvi INNER JOIN Quyen_Nhom on Donvi.ID = Quyen_Nhom.Manhom where Donvi.Madonvi like '"& Session("bMaDonVi") &"' and Quyen_Nhom.Maloaivanthu = '7'"
				
				bCanbo="Select Mavanthu From Quyen Where Macanbo ='" & Session("bMaCB") & "' and Maloaivanthu='7'"

				bCapnhat="Select ID from Totrinh Where NguoiCN='" & Session("bMaCB") &"'"

'Co quyen "Phan quyen doc TT"
				if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),4)="1" then
					if session("sSQLTotrinh")="" then
						sSQL="Select * from Totrinh Where DonviXL like '%" & Session("bMaDonVi") &"' OR Totrinh.ID in (" & bNhom &") OR Totrinh.ID in (" & bDonvi &") OR Totrinh.ID in (" & bCanbo &") OR NguoiCN='" & Session("bMaCB") &"' " & oSQL
						bPrintValue="Select * from Totrinh Where DonviXL like '%" & Session("bMaDonVi") &"' OR Totrinh.ID in (" & bNhom &") OR Totrinh.ID in (" & bDonvi &") OR Totrinh.ID in (" & bCanbo &") OR NguoiCN='" & Session("bMaCB") &"' " 
					else
						bPrintValue=session("sSQLTotrinh")
						sSQL=session("sSQLTotrinh") & " "& oSQL
					end if
				else
'Cac truong hop #
					if session("sSQLTotrinh")="" then
						sSQL="Select * from Totrinh Where Totrinh.ID in (" & bNhom &") OR Totrinh.ID in (" & bDonvi &") OR Totrinh.ID in (" & bCanbo &") OR NguoiCN='" & Session("bMaCB") &"' "& oSQL
						bPrintValue="Select * from Totrinh Where Totrinh.ID in (" & bNhom &") OR Totrinh.ID in (" & bDonvi &") OR Totrinh.ID in (" & bCanbo &") OR NguoiCN='" & Session("bMaCB") &"' "
					else
						bPrintValue=session("sSQLTotrinh")
						sSQL=session("sSQLTotrinh") & " "& oSQL
					end if
				end if
			end if
		End select
	Set Rec=server.CreateObject("ADODB.Recordset")
	Rec.CursorType=3
	Rec.CacheSize=5
	Rec.Open sSQL,Conn	
	Dim nRecCount	' Number of records found
	Dim nPageCount	' Number of pages of records we have
	Dim nPage	' Current page number

	sPage=request("Page")
	nPage=CLng(sPage)
	if nPage="" then 
		nPage=1
	end if
	if sPage<>"" then
		Session("pagettgv")=nPage
	else
		nPage=Session("pagettgv")
	end if

	if Rec.EOF and Rec.BOF then
		nPageCount=0
	end if
	bDisplay=Request("bDisplay")

	if  bDisplay then
		sSQL="Select * from Totrinh where ID like "& request("bID")
		Set RecDisplay=Server.CreateObject("ADODB.Recordset")
		RecDisplay.CursorType=3
		RecDisplay.CacheSize=5
		RecDisplay.Open sSQL,Conn
		if RecDisplay.RecordCount>0 then
			bID=RecDisplay("ID")
			bNgayden=RecDisplay("Ngayden")
			bSoden=RecDisplay("Soden")
			bNoigui=RecDisplay("Noigui")
			bSokyhieu=RecDisplay("Sokyhieu")
			bNgayky=RecDisplay("NgayCV")
			bNguoinhan=RecDisplay("Nguoinhan")
			bTrichyeu=RecDisplay("Trichyeu")
			bYkien=RecDisplay("Ykienchidao")
			bDonviXL=RecDisplay("DonviXL")
			bHanXL=RecDisplay("HanXL")
		end if
		RecDisplay.Close
		Set RecDisplay=nothing
	end if

%>	
<script language=VBScript runat=server>
	' H&#224;m &#273;&#7883;nh d&#7841;ng l&#7841;i ng&#224;y M/D/Y-> D/M/Y
	Function FormatDate(vDate)
	   If Not IsNull(vDate) Then
	        vM = Right("0" & Month(vDate), 2)
	        vD = Right("0" & Day(vDate), 2)
	        vY = Right("19" & Year(vDate), 4)
	        FormatDate = vD & "/" & vM & "/" & vY
	   End If
	End Function
	Function ModiString(mess_s)
		message = Replace("" & mess_s,"'", "''")
		ModiString=message
	End function
	Function SaveDate(vDate)
		dim bvitri1
		dim bvitri2
	   vDate=trim(cstr(vDate))
	   bvitri1=instr(1,vDate,"/")
	   bMonth=left(vDate,bvitri1-1)
	   bvitri2=instr(bvitri1+1,vDate,"/")
	   Dim Temp
	   Temp=right(vDate,len(vDate)-bvitri1)
	   bDay=left(Temp,bvitri2-bvitri1-1)
	   bYear=right(vDate,len(vDate)-bvitri2)
       SaveDate=bDay+"/"+bMonth+"/"+bYear
	End Function
</script>
<script language=javascript>
function OpenW(bCom){
//HienSX
		sort=Noidung.Sort.value;
		remote = window.open('frmsearchTotrinh.asp?sort='+sort+'&bComm=VTDEN','new_page','width=600,height=263,top=20,left=160').focus();
	}
</script>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
//HienSX
function Sort(SortKey){
	if (document.Noidung.Sort.value.indexOf(SortKey)== -1)
		document.Noidung.Sort.value=SortKey;
	else {
		if (document.Noidung.Sort.value.indexOf('Rev')== -1)
			document.Noidung.Sort.value='Rev' + SortKey;
		else
			document.Noidung.Sort.value= SortKey;
	}
	Noidung.target="right";
	Noidung.action="frmdsTotrinh.asp?sort=" + Noidung.Sort.value;
	Noidung.submit();
}
function SetFocus(){
	window.Noidung.CmdSearch.focus();
}

function ChangePage(){
	strURL= Noidung.page.value;
	window.Noidung.target="right";
	window.Noidung.action = strURL;
	window.Noidung.submit();
}

function CmdAdd_Onclick() {
	window.Noidung.target="right";
//HienSX
	window.Noidung.action="frmTotrinh.asp?bComm=add&sort="+Noidung.Sort.value;
	window.Noidung.submit();
}

function CmdEdit_Onclick() {
	window.Noidung.target="right";
//HienSX
	window.Noidung.action="frmTotrinh.asp?bComm=edit&sort="+Noidung.Sort.value;
	window.Noidung.submit();
}

function CmdPrint_Onclick() {
	Noidung.target="_blank";
	Noidung.action="frmPrintTotrinh.asp";
	Noidung.submit();
}
function CmdRight_Onclick(){
	window.Noidung.target="right";
	window.Noidung.action="duyetcanbodvxl.asp?bstepduyet=0&MaVT="+"<%=bID%>"+"&bMaLoaiVT=7";
	window.Noidung.submit();
}
function CmdFinish_Onclick(){
	window.Noidung.target="right";
	window.Noidung.action="frmHTXLTotrinh.asp?IDTotrinh="+"<%=bID%>";
	window.Noidung.submit();
}

function CmdSearch_Onclick() {
	OpenW("");
	return;
	if(trim(Noidung.TxtTungay.value)!=""){
		if (!isDate(Noidung.TxtTungay.value)){
			alert("Ngày không hợp lệ");
			Noidung.TxtTungay.focus();
			return false;
		}
		else{
			if(trim(Noidung.TxtDenngay.value)==""){
				alert("Cho biết đến ngày nào");
				Noidung.TxtDenngay.focus();
				return false;
			}
		}
	}
	if(Noidung.TxtDenngay.value!=""){	
		if (!isDate(Noidung.TxtDenngay.value)){
			alert("Ngày không hợp lệ");
			Noidung.TxtDenngay.focus();
			return false;
		}
		else{
			if(trim(Noidung.TxtTungay.value)==""){
				alert("Cho biết từ ngày nào");
				Noidung.TxtTungay.focus();
				return false;
			}
		}
	}
	window.Noidung.target="right";
	window.Noidung.action="frmdsTotrinh.asp?bComm=search";
	window.Noidung.submit();
}
function CmdDelete_Onclick() {	
	if(!confirm("Bạn có muốn xóa không ?")){
		return false;	
	}
	window.Noidung.target="right"
	window.Noidung.action="frmdsTotrinh.asp?page="+"<%=nPage%>"+"&bComm=delete"+"&bnam="+"<%=bnam%>";
	window.Noidung.submit();
}

//-->
</SCRIPT>
<%if bMsg<>"" then%>
	<p align=center><font color=red><%=bMsg%></p>
<%end if%>
<LINK href="../styles/styles.css" type=text/css rel=STYLESHEET>
<body leftmargin=2 topmargin=0 style="font-family:Times New Roman" onload="SetFocus()">
<form name="Noidung" method="post">
<!-- HienSX -->
<Input TYPE="hidden" name="Sort" value="<%=sort%>">
<INPUT TYPE="hidden" name=NgayIn value="<%=bNgayIn%>">
<INPUT TYPE="hidden" name=PrintValue value="<%=bPrintValue%>">
<!-- Form nhap lieu -->
  <table border="0" width="100%" bgcolor="#BDD5D0" style="Font-family:Times New Roman;font-size:12pt;BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0">
	<%if bDisplay then%>
		<Input type=hidden name=TxtID value='<%=bID%>'>
		<%Session("bMaVB")=bID%>
	<%else%>
		<Input type=hidden name=TxtID>
	<%end if%>
<!-- Buttons -->
    <tr>
      <TD WIDTH="100%" COLSPAN="7" BGCOLOR="#000080"><P ALIGN="CENTER"><FONT FACE="Times New Roman" COLOR="#FFFFFF" SIZE=3>TỜ TRÌNH - GIAO VIỆC</FONT></P></TD>
    </tr>
	<tr>
	<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then%>
		<td width="14%"><Button name="CmdAdd" lang="ja" onClick="return CmdAdd_Onclick()" style="font-family: Arial; width:100%" accesskey="T"><u>T</u>hêm</Button></td>
	<%else%>
		<td width="14%"><Button name="CmdAdd" lang="ja" onClick="return CmdAdd_Onclick()" style="font-family: Arial; width:100%" accesskey="T" disabled><u>T</u>hêm</Button></td>
	<%end if%>
	<% if (Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin")) and bDisplay then%>
		<td width="14%"><Button name="CmdEdit" lang="ja" onClick="return CmdEdit_Onclick()" style="font-family: Arial; width:100%" accesskey="S"><u>S</u>ửa</Button></td>
		<td width="14%"><Button name="CmdDelete" lang="ja" onClick="return CmdDelete_Onclick()" style="font-family: Arial; width:100%" accesskey="X"><u>X</u>óa</Button></td>
	<%else%>
		<td width="14%"><Button name="CmdEdit" lang="ja" onClick="return CmdEdit_Onclick()" style="font-family: Arial; width:100%" accesskey="S" disabled><u>S</u>ửa</Button></td>
		<td width="14%"><Button name="CmdDelete" lang="ja" onClick="return CmdDelete_Onclick()" style="font-family: Arial; width:100%" accesskey="X" disabled><u>X</u>óa</Button></td>
	<%end if%>
		<td width="14%"><Button name="CmdSearch" lang="ja" onClick="return CmdSearch_Onclick()" style="font-family: Arial; width:100%" accesskey="m">Tì<u>m</u> kiếm</Button></td>
	<% if (Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),4)="1" or Session("IsAdmin")) and bDisplay then%>
		<td width="15%"><Button name="CmdRight" lang="ja" onClick="return CmdRight_Onclick()" style="font-family: Arial; width:100%" accesskey="P"><u>P</u>hân 
        quyền</Button></td>
	<%else%>
		<td width="15%"><Button name="CmdRight" lang="ja" onClick="return CmdRight_Onclick()" style="font-family: Arial; width:100%" accesskey="P" disabled><u>P</u>hân 
        quyền</Button></td>
	<%end if%>
	<% if (Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),5)="1" or Session("IsAdmin")) and bDisplay then%>
		<td width="15%"><Button name="CmdFinish" lang="ja" onClick="return CmdFinish_Onclick()" style="font-family: Arial; width:100%" accesskey="H"><u>H</u>oàn thành XL</Button></td>
	<%else%>
		<td width="15%"><Button name="CmdFinish" lang="ja" onClick="return CmdFinish_Onclick()" style="font-family: Arial; width:100%" accesskey="P" disabled><u>H</u>oàn thành XL</Button></td>
	<%end if%>	
		<td width="14%"><Button name="CmdPrint" lang="ja" onClick="return CmdPrint_Onclick()" style="font-family: Arial; width:100%" accesskey="I"><u>I</u>n</Button></td>
	</tr>
</table>
<!-- Danh sach To trinh -->
<table border="0" width="100%" style="Border-color:#C0C0C0; BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid">
	<tr bgcolor="#BDD5D0">
		<td width="4%" nowrap></td>
		<td width="1%" align="center"><A onmouseover="window.status='';return true" HREF="javascript:Sort('Attach')">&nbsp;<IMG border=0 SRC=../images/attach.gif>&nbsp;</A></td>
		<td width="10%" nowrap align="center"><A onmouseover="window.status='';return true" HREF="javascript:Sort('Num')"><b>Số đến</b>
		<% if bImgNum<>"" then %><IMG SRC="<%=bImgNum%>" BORDER=0><%end if%> </A></td>
		<td width="13%" nowrap align="center"><A onmouseover="window.status='';return true" HREF="javascript:Sort('Date')"><b>Ngày đến</b>&nbsp;
		<% if bImgDate<>"" then %><IMG SRC="<%=bImgDate%>" BORDER=0><%end if%> </A></td>
		<td width="47%" nowrap><A onmouseover="window.status='';return true" HREF="javascript:Sort('Subject')">&nbsp;&nbsp;<b>Tr&#237;ch y&#7871;u</b>&nbsp;&nbsp;&nbsp;
		<% if bImgSubject<>"" then %><IMG SRC="<%=bImgSubject%>" BORDER=0><%end if%>
		</A></td>
		<td width="25%" nowrap><A onmouseover="window.status='';return true" HREF="javascript:Sort('PlaceSend')">&nbsp;&nbsp;<b>Nơi gửi</b>&nbsp;&nbsp;&nbsp;<% if bImgPlaceSend<>"" then %><IMG SRC="<%=bImgPlaceSend%>" BORDER=0><%end if%></A></td>
	</tr>
   <% 
	If Not Rec.Eof Then
		nRecCount = Rec.RecordCount
		Rec.PageSize = 20
		nPageCount = Rec.PageCount
		If nPage < 1 then
			nPage = 1			
		End If
		if nPage > nPageCount Then
			nPage=nPageCount
		end if
		cnt=(pg-1)*pgsize + 1		    
		STT=1
		rec.AbsolutePage=nPage
		howmanyrecs=0
		do while not Rec.EOF and howmanyrecs<rec.PageSize
			if (cnt/2=int(cnt/2)) then
				color="#eeeecc"
			else
				color="#F8F9D9"
			end if

			if rec("attach") then
				imagesAttach="<IMG border=0 SRC=../images/attach.gif>"
			else				
				imagesAttach=""
			end if
%>
	<%if "'" & Rec("ID") & "'"=Request("bID") then
		color="#BDD7D6"
	end if
	%>
	<tr id=mnu_<%=STT%> style="BORDER-RIGHT: #e7e7e7 1px solid; BORDER-TOP: #e7e7e7 1px solid; BORDER-LEFT: #e7e7e7 1px solid; COLOR: #666666; BORDER-BOTTOM: #e7e7e7 1px solid; HEIGHT: 21px; BACKGROUND-COLOR: <%=color%>"  onmouseover="javascript:MouseOverMenu('mnu_<%=STT%>')" onmouseout="javascript:MouseOutMenu('mnu_<%=STT%>','<%=color%>')">
		<td width="4%" align="center"><a href='xemnoidung.asp?LoaiVt=7&bMa=<%=Rec("ID")%>&bNam=<%=year(Rec("Ngayden"))%>' target="_blank"><p title="Xem n&#7897;i dung v&#259;n th&#432;"><IMG border=0 SRC=Thuthuong.gif></p></a></td>
		<td width="1%" align="center"><A href='xemnoidung.asp?LoaiVt=7&bMa=<%=Rec("ID")%>&bNam=<%=year(Rec("Ngayden"))%>' target="_blank"><p title="Xem n&#7897;i dung v&#259;n th&#432;"><%=imagesAttach%></p></A></td>
		<td width="10%" align=center><A style='cursor:hand;color:blue;text-decoration: none' href="frmdsTotrinh.asp?sort=<%=sort%>&Page=<%=nPage%>&bDisplay=True&bID='<%=Rec("ID")%>'&bNam=<%=year(Rec("Ngayden"))%>">
		<%=Rec("Soden")%></A></td>
		<td width="13%" align="center"><A style='cursor:hand;color:blue;text-decoration: none' href="frmdsTotrinh.asp?sort=<%=sort%>&Page=<%=nPage%>&bDisplay=True&bID='<%=Rec("ID")%>'&bNam=<%=year(Rec("Ngayden"))%>">
		<%=FormatDate(Rec("Ngayden"))%></a></td>
		<td width="47%"><a style='cursor:hand;color:blue;text-decoration: none' href="frmdsTotrinh.asp?sort=<%=sort%>&Page=<%=nPage%>&bDisplay=True&bID='<%=Rec("ID")%>'&bNam=<%=year(Rec("Ngayden"))%>"><%=Rec("Trichyeu")%></A> </td>
		<td width="25%"><a style='cursor:hand;color:blue;text-decoration: none' href="frmdsTotrinh.asp?sort=<%=sort%>&Page=<%=nPage%>&bDisplay=True&bID='<%=Rec("ID")%>'&bNam=<%=year(Rec("Ngayden"))%>"><%=Rec("Noigui")%></A> </td>
	</tr>

	<%
		if  Session("VanBan")="" then
			Session("VanBan")="-" & Rec("ID") 
		else
			Session("VanBan")=Session("VanBan") & "-" & Rec("ID") 
		end if
	%>
	<%		STT=STT+1
			Rec.MoveNext
			cnt=cnt+1
			howmanyrecs=howmanyrecs+1
	loop
		Session("VanBan")=Session("VanBan") & "-"
	end if
	rec.Close
	set rec=nothing
%>
    </table>
<!-- Phan trang -->
<br>
<table width="98%" cellspacing=0 cellpadding=0>
<tr>
<% if nPage > 0 and nPageCount >0  then %>  
	<td width="20%"><b>Trang&nbsp; <%=Session("pagettgv")%>/<%=nPageCount%></b></td>
	<td width= "80%" align="right">
	<% if nPageCount > 1 then %>    
		Chuyển nhanh tới trang:&nbsp;
		<select name="page" style="width:45;height: 25;font-size:8pt" size=1 onchange="javaScript:ChangePage()">
			<% for counter = 1 to nPageCount%>	
				<%strURL= "frmdsTotrinh.asp?page="+ cstr(counter) + "&bComm=" %>
				<option value="<%=strURL%>" <%=chkSelected(counter, Session("pagettgv"))%>><%=counter%></option>
			<% next %>    
		</select>
		</td>                                  
	<% end if %>             
<% 'else %>
<% end if %>
  </tr>
</table>
</form>
</font>
</body>

<%
	Conn.Close
	set Conn=nothing
%>